package com.py.inbound.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.py.inbound.domain.WhInventory;
import com.py.inbound.domain.WhOutbound;
import com.py.inbound.service.IWhInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/inventory")
public class WhInventoryController extends BaseController {
    @Autowired
    private IWhInventoryService whInventoryService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:inventory:list")
    @GetMapping("/list")
    public TableDataInfo list(WhInventory whInventory) {
        startPage();
        List<WhInventory> list = whInventoryService.selectWhInventoryList(whInventory);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:inventory:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WhInventory whInventory) {
        List<WhInventory> list = whInventoryService.selectWhInventoryList(whInventory);
        ExcelUtil<WhInventory> util = new ExcelUtil<WhInventory>(WhInventory.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("system:inventory:query")
    @GetMapping(value = "/{inventoryQueryId}")
    public AjaxResult getInfo(@PathVariable("inventoryQueryId") Long inventoryQueryId) {
        return success(whInventoryService.selectWhInventoryByInventoryQueryId(inventoryQueryId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("system:inventory:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WhInventory whInventory) {
        return toAjax(whInventoryService.insertWhInventory(whInventory));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("system:inventory:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WhInventory whInventory) {
        return toAjax(whInventoryService.updateWhInventory(whInventory));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:inventory:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{inventoryQueryIds}")
    public AjaxResult remove(@PathVariable Long[] inventoryQueryIds) {
        return toAjax(whInventoryService.deleteWhInventoryByInventoryQueryIds(inventoryQueryIds));
    }

    @GetMapping("/WhInventoryList")
    public TableDataInfo WhInventoryList(WhInventory whInventory) {
        System.out.println("WhInventory:" + whInventory);

        startPage();
        List<WhInventory> list = whInventoryService.WhInventoryList(whInventory);
        return getDataTable(list);
    }

    @GetMapping("/whInventoryTotle")
    public WhInventory outTotle() {
        WhInventory whInventory = whInventoryService.whInventoryTotle();
//        System.out.println("撒旦撒啊:" + whInventory);
        return whInventory;
    }
}
